package com.whynot.frame.jdk.jdk8.stream;

import com.whynot.frame.jdk.jdk8.lambda.model.User;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import  java.util.stream.Collectors;

public class StreamCol {
    List<User> list = new ArrayList<User>();


    public void add(){


        for (int i = 0 ; i < 10 ; i++){
            User user = new User();
            user.setPwd("123");
            user.setUsername("cy"+i);
            user.setId("1"+i);
            list.add(user);
        }
    }

    public void stream(){
        Map<String,User> map = list.stream().collect(Collectors.toMap(User::getId,(User)->User ));
        System.out.println(map);
    }
}
